clear all
program drop _all
set more off
set mem 600m

cd "C:\Users\master\Dropbox\Research\mexican_repatriates2\data\kwan"
use "D:\raw\1940.dta"

keep statefip county bpl bpld fbpl mbpl perwt

keep if bpld<15000 | bpld==90011 | bpld==90021 | bpld==90022
drop if bpl==200 | fbpl==200 | mbpl==200

replace county = (1000*statefip) + (county/10)

* Arizona
replace county = 4009 if county == 4011

* Louisiana
replace county = 22097 if county == 22039
replace county = 22019 if county == 22011 | county == 22003 | county == 22053

* New Mexico
replace county = 35017 if county == 35023
replace county = 35019 if county == 35011
replace county = 35005 if county == 35025

* Nevada
replace county = 32013 if county == 32027
replace county = 32009 if county == 32021

* Oklahoma
replace county = 40031 if county == 40033

* Oregon
replace county = 41013 if county == 41031 | county == 41017

* Texas
replace county = 48141 if county == 48229 | county == 48109
replace county = 48137 if county == 48385
replace county = 48355 if county == 48273 | county == 42849
replace county = 48061 if county == 48489
replace county = 48427 if county == 48407

* Utah
replace county = 49047 if county == 49009
replace county = 49051 if county == 49013

collapse (sum) pop40_native=perwt, by(county)

save native_pop1940.dta, replace 
